package com.jic.order.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.order.entity.OrderPayDetail;
import com.jic.order.mapper.OrderPayDetailMapper;
import com.jic.order.request.OrderNoPage;
import com.jic.order.service.OrderPayDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
@Slf4j
public class OrderPayDetailServiceImpl implements OrderPayDetailService {

    @Resource
    private OrderPayDetailMapper orderPayDetailMapper;
    @Override
    public long insert(OrderPayDetail orderPayDetail) {
        return orderPayDetailMapper.insert(orderPayDetail);
    }

    @Override
    public long delete(Long id) {
        return orderPayDetailMapper.delete(id);
    }

    @Override
    public long update(OrderPayDetail orderPayDetail) {
        return orderPayDetailMapper.update(orderPayDetail);
    }

    @Override
    public OrderPayDetail queryByPrimaryKey(Long id) {
        return orderPayDetailMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderPayDetail> query(OrderPayDetail orderPayDetail) {
        return orderPayDetailMapper.query(orderPayDetail);
    }

    @Override
    public PageResult<OrderPayDetail> queryPage(OrderPayDetail orderPayDetail, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<OrderPayDetail> list = orderPayDetailMapper.queryPage(startIndex, pageQuery.getLimit(), orderPayDetail);
        long count = orderPayDetailMapper.queryPageCount(orderPayDetail);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }


}
